//
// Created by DengLibin on 2019/1/11 0011.
//

/**
删除排序数组中的重复项
 **/
#include <iostream>
#include <vector>
using  namespace std;
int removeDuplicates(vector<int>& nums) {
    if(nums.size() == 0){
        return 0;
    }
    int index = 0;//下标
    for(int num : nums){ //遍历
        if(num>nums[index]){ //当前数大于下标指向的数
            //下标+1 再值赋值
            nums[++index] = num;
        }
    }
    return index+1;
}

int main59(){
    vector<int > v;
    v.push_back(0);
    v.push_back(0);
    v.push_back(1);
    v.push_back(1);
    v.push_back(1);
    v.push_back(2);
    v.push_back(2);
    v.push_back(3);
    v.push_back(3);
    v.push_back(4);
    int len = removeDuplicates(v);
    cout << len<<endl;
    for(int num : v){
        cout << num<<",";
    }
    return 0;
}